﻿/*              Copyright(c) 2008 Dave Sexton              *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;

namespace DaveSexton.DocToMaml
{
	[Serializable]
	internal struct ConceptualImage : IEquatable<ConceptualImage>, IEquatable<string>
	{
		#region Public Properties
		public static readonly ConceptualImage Empty = new ConceptualImage();

		public string File { get; private set; }

		public string AlternateText { get; private set; }

		public string Id { get; private set; }
		#endregion

		#region Private / Protected
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="ConceptualImage" /> structure.
		/// </summary>
		public ConceptualImage(string file, string alternateText, string id)
			: this()
		{
			File = file;
			AlternateText = alternateText;
			Id = id;
		}
		#endregion

		#region Methods
		public override bool Equals(object obj)
		{
			if (obj is ConceptualImage)
				return Equals((ConceptualImage) obj);
			else
			{
				string str = obj as string;

				return str != null && Equals(str);
			}
		}

		public override int GetHashCode()
		{
			return (Id ?? string.Empty).GetHashCode();
		}

		public static bool operator ==(ConceptualImage image1, ConceptualImage image2)
		{
			return image1.Equals(image2);
		}

		public static bool operator !=(ConceptualImage image1, ConceptualImage image2)
		{
			return image1.Equals(image2);
		}

		public static bool operator ==(ConceptualImage image1, string id)
		{
			return image1.Equals(id);
		}

		public static bool operator !=(ConceptualImage image1, string id)
		{
			return image1.Equals(id);
		}
		#endregion

		#region IEquatable<ConceptualImage> Members
		public bool Equals(ConceptualImage other)
		{
			return string.Equals(Id, other.Id, StringComparison.OrdinalIgnoreCase);
		}
		#endregion

		#region IEquatable<string> Members
		public bool Equals(string other)
		{
			return string.Equals(Id, other, StringComparison.OrdinalIgnoreCase);
		}
		#endregion
	}
}
